function validator(user,pass)
{ 


if (user.length==0 || pass.length==0)
  {
  if(user.length == 0) {alert("Masukkan username anda terlebih dahulu");}    
  else if(pass.length == 0) {alert("Masukkan password anda terlebih dahulu");}
  return;
  }
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  } 
  
 
xmlhttp.onreadystatechange=function()
  {
  
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    
    if(xmlhttp.responseText == "berhasil")
    {
        window.location="index.php";
        
    }
    else
    {alert("Username dan/atau password yang anda masukkan salah");}    
    }   
  }
  
xmlhttp.open("GET","login_validate.php?u="+user+"&p="+pass,true);
xmlhttp.send();
}
